class QuestionsController < ApplicationController
  helper :sparklines
  
  def index
    @questions = Question.find :all
  end

  def filter
    vote_questions = Question.find_questions_with_votes(params[:vote].to_f)
    speech_questions = Question.find_questions_with_speeches(params[:speech].to_f)
    attendance_questions = Question.find_questions_with_attendances(params[:attendance].to_f)
    rebellion_questions = Question.find_questions_with_rebellion(params[:rebellion].to_f)
    
    @questions = Array.new
    (vote_questions & speech_questions & attendance_questions & rebellion_questions).each do |qid|
      @questions << Question.find(qid, :include=> [:sitting])
    end
    
    x = (vote_questions & speech_questions & attendance_questions & rebellion_questions)
    render :partial => 'question', :locals => {
      :rebellion_questions => rebellion_questions,
      :speech_questions => speech_questions,
      :vote_questions => vote_questions,
      :attendance_questions => attendance_questions
      }
  end
end
